﻿using System.Drawing;
using GraphDrawing.Graph.Model;

namespace GraphDrawing.Graph.Behaviors
{
    public class ConnectionSelectionState : ModelStatePresenter
    {
        readonly Point point;
        readonly ConnectionModel connection;

        public ConnectionSelectionState(ModelStateContext context, Point p, ConnectionModel connection)
            : base(context)
        {
            point = p;
            this.connection = connection;
            context.Graph.ClearSelection();
        }

        public override void OnMouseMove(Point p)
        {
        }

        public override void OnMouseUp(Point p)
        {
            var gPoint = context.CanvasModel.ViewPort.ClientToGlobal(p);
            if (connection.HitTest(gPoint))
                context.Graph.Select(connection);
        }
    }
}